# -*- coding:utf-8 -*-
from rest_framework import serializers

from Apps.System.models.role_menu import Menu
from Apps.User.models import User
import logging

from Apps.User.ser import UserSerializer

logger = logging.getLogger('django')


class MenuSer(serializers.ModelSerializer):
    creator = UserSerializer(read_only=True)
    moderator = UserSerializer(read_only=True)

    class Meta:
        model = Menu
        fields = "__all__"

    def get_read_creator(self, obj):
        return "343434"


class getMenuTreeSer(serializers.ModelSerializer):
    class Meta:
        model = Menu
        # fields = ["id", "menuType", "parentId", "name"]
        fields = "__all__"


class getMenuSidebarSer(serializers.ModelSerializer):
    class Meta:
        model = Menu
        # fields = ["id", "menuType", "parentId", "name", "icon", "web_path", "perms"]
        fields = "__all__"


# 获取父级菜单
class ParentMenuSer(serializers.ModelSerializer):
    class Meta:
        model = Menu
        fields = ['id', 'name']
